/*
 * File: $Id: mbport.h,v 1.19 2010/06/06 13:54:40 wolti Exp $
 */

#ifndef _MB_PORT_H
#define _MB_PORT_H

#ifdef __cplusplus
PR_BEGIN_EXTERN_C
#endif

/* ----------------------- Type definitions ---------------------------------*/



/* ----------------------- Supporting functions -----------------------------*/


/* ----------------------- Serial port functions ----------------------------*/

BOOL            xMBPortSerialInit(	UCHAR		ucPort,
										ULONG		ulBaudRate,
										UCHAR		ucDataBits,
										eMBParity	eParity		);

void            vMBPortClose( void );

void            xMBPortSerialClose( void );

void            vMBPortSerialEnable( BOOL xRxEnable, BOOL xTxEnable );

BOOL            xMBPortSerialGetByte( CHAR * pucByte );

BOOL            xMBPortSerialPutByte( CHAR ucByte );

/* ----------------------- Timers functions ---------------------------------*/
BOOL            xMBPortTimersInit( USHORT usTimeOut50us );

void            xMBPortTimersClose( void );

void            vMBPortTimersEnable( void );

void            vMBPortTimersDisable( void );

void            vMBPortTimersDelay( USHORT usTimeOutMS );

/* ----------------------- Callback for the protocol stack ------------------*/

/* Callback function for the porting layer when a new byte is available.
 *
 * Depending upon the mode this callback function is used by the RTU or
 * ASCII transmission layers. In any case a call to xMBPortSerialGetByte()
 * must immediately return a new character.
 *
 * TRUE if a event was posted to the queue because a new byte was received.
 * The port implementation should wake up the tasks which are currently blocked on the eventqueue.
 */

extern          BOOL( *pxMBFrameCBByteReceived )		( void );
extern          BOOL( *pxMBFrameCBTransmitterEmpty )	( void );
extern          BOOL( *pxMBPortCBTimerExpired )			( void );

#ifdef __cplusplus
PR_END_EXTERN_C
#endif
#endif
